/*
* @Author: jingyu.ma
* @Date:   2017-07-12 20:39:04
* @Last Modified by:   jingyu.ma
* @Last Modified time: 2017-08-06 21:33:24
*/

import React from 'react';
import { connect } from 'react-redux';
import { Router, Route, Link, hashHistory } from 'react-router';
import 'css/components/publishList.less';
import { changeCommentId } from 'action/commont.js';


class Mypublish extends React.Component{
    constructor(props){
        super(props); 
    }
    goToDetail(id){
        this.props.goToDetail(id);
    }
    cacalPublish(id){
        this.props.cacalOrder(id);
    }
    hasMoreList(){
        this.props.getMoreList();
    }
    render(){
        let self = this;
        let publishList = this.props.publishList.list ? this.props.publishList.list.map(function(item){
            return(
                <div className="services-list" key={item.id}>
                    <div className="publish-mess" >
                        <div className="message-title" onClick={()=>self.goToDetail(item.id)}>
                            <span  className="order-id">{item.courses[0]}</span>
                        </div>
                        <div className="publish-body">
                            <p className="remark">{item.content}</p>
                            <p className="price">{item.price}元/小时</p>
                            <p className="name">{item.name}</p>
                        </div>
                        <div className="publish-footer">
                            <span className="publish-time">{item.dtime}</span>
                            <span className="publish-btn">
                            {
                                item.type == 5?
                                <a className="btn cacal" onClick={()=>{self.cacalpublish()}}>废弃</a>:''
                                
                            }
                            </span>
                        </div>  
                    </div> 
                </div>
            );
        }): <div className="list-mess">暂时无数据</div>;
        return(
            <div className="require-list">
                {publishList}
                {
                    ((this.props.publishList.total/10).toFixed(0)>this.props.publishList.pageNo && this.props.publishList.total!=0)?
                    <div className="hasMore" onClick={()=>this.hasMoreList()}>加载更多</div>:''
                }
            </div>
        );
    }
}

export default Mypublish;